#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QWidget>
#include <QTextStream>
#include "ifilebuffer.h"
#include "progresslistener.h"
#include "infowindow.h"

namespace Ui {
class MainWindow;
}

class MainWindow : public QWidget
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

public slots:

    void onFileLoaded(QString fileName, qint64 fileSize);
    void onFileLoadingError(QString fileName, QString error, IFileBuffer::State newState);
    void onFileSaved(QString fileName);
    void onFileSavingError(QString fileName, QString error);
    void onDataCleared();

private slots:

    void on_loadFile_clicked();

    void on_saveFile_clicked();

    void on_clearBuffer_clicked();

    void on_clearLog_clicked();

private:
    Ui::MainWindow *ui;
    IFileBuffer *fb;
    ProgressListener* pl;
    InfoWindow infoWindow;

    QString logMsg;
    QTextStream logStream;
    QTextStream &logBegin();
    QString logEnd();
    void log(QString msg);

    void updateStatus();
    void setStatusFree();
    void setStatusLoaded(qint64 fileSize);
};

#endif // MAINWINDOW_H
